<div class="col-lg-12">

	<button id="btn-add-new" class="btn btn-success">Add new offer</button>


	<div style="display: none" id="panel-form-add" class="panel panel-primary">
	  <div class="panel-heading">
	    <h3 class="panel-title">Add new offer</h3>
	  </div>
	  <div class="panel-body">
			<form id="form-add-offer" action='<?php echo site_url("/admin/offers/add/$banner->networkId");?>' role="form" method="post" accept-charset="utf-8">

				<div class="row">
					  <div class="form-group col-lg-6">
					    <input type="text" class="form-control" name="name" id="name" placeholder="offer name">
					    <span class="help-block"></span>
					  </div>

					  <div class="form-group col-lg-6">
					    <input type="text" class="form-control" name="des" id="des" placeholder="offer description">
					  </div>
				</div>

				<div class="row">
					  <div class="form-group col-lg-6">
					    <input type="text" class="form-control" name="url" id="url" placeholder="Tracking URL">
					    <span class="help-block"></span>
					  </div>

					  <div class="form-group col-lg-6">
					    <input type="text" class="form-control" name="image" id="image" placeholder="Image link">
					  </div>
				</div>  

				<div class="row">
					  <div class="form-group col-lg-6">
					    <input type="text" class="form-control" name="payout" id="payout" placeholder="Payout">
					    <span class="help-block"></span>
					  </div>

					  <div class="form-group col-lg-6">
			                <select  class="form-control" name="countryId" title="Please select country!" id="countryId">
			                    <?php 
			                        echo "<option value='222'>United States</option>";
			                        echo "<option value='221'>United Kingdom</option>";
			                        echo "<option value='38'>Canada</option>";
			                        echo "<option value='13'>Australia</option>";
			                        echo "<option value='73'>France</option>";

			                        foreach ($countries as $country) {
			                                      
			                            if ($country->id == 222 || $state->id == 38) {
			                                echo "<option value='$country->id' id='_state'> $country->name</option>";
			                            } else {
			                                echo "<option value='$country->id' > $country->name</option>";
			                            }
			                                        
			                        }// end foreach
			                    ?>        
			                </select>
					  </div>
				</div>


				  <button type="submit" class="btn btn-success">Submit</button>
				  <button type="submit" class="btn btn-warning" id="btn-cancel">Cancel</button>
			</form>
	  </div>
	</div>



	<hr />


	<div class="panel panel-danger">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php echo $banner->networkName ?> - Curent Offers</h3>
	  </div>
	  <div class="panel-body">
			<table class="table table-bordered">
			  	<thead>
			  		<th>Name</th>
			  		<th>Description</th>
			  		<!-- <th>Tracking URL</th> -->
			  		<th>Image</th>
			  		<th>Payout</th>
			  		<th>Country</th>
			  		<th>Action</th>
			  	</thead>
			  	<tbody>
			  		
			  		<?php foreach ($offers as $offer) { ?>

			  			<tr>

				  			<td>
				  				<?php echo $offer->name ?>
				  			</td>

				  			<td>
				  				<?php echo $offer->des ?>		
				  			</td>

<!-- 				  			<td>
				  				<a href="<?php echo $offer->url ?>">
				  					<?php echo $offer->url ?>
				  				</a>
				  			</td> -->

				  			<td>
				  				<image style="width: 70px; height: 70px;" class="img-thumbnail" src="<?php echo $offer->image ?>" />
				  			</td>		  			

				  			<td>
				  				<?php echo $offer->payout ?>
				  			</td>

				  			<td>
				  				<?php echo $offer->countryId ?>
				  			</td>		  			

				  			<td>

								<!-- Single button -->
								<div class="btn-group">
								  <button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">
								    Action <span class="caret"></span>
								  </button>
								  <ul class="dropdown-menu" role="menu">
								    <li><a href="#">Edit</a></li>
								    <li class="divider"></li>
								    <li><a class="btn-deletete" href='<?php echo site_url("/admin/offers/remove/$banner->networkId/$offer->id") ?>'>Delete</a></li>
								  </ul>
								</div>

							</td>
				  		</tr>	  				

			  		<?php } ?>

			  			


			  	</tbody>
			</table>	    
	  </div>
	</div>



	
</div>




<script type="text/javascript">
	$(document).ready(function() {

		$("#btn-add-new").click(function(event) {
			
			$("#panel-form-add").show('slow');
			$(this).hide('fast');
		}); //end click

		$("#btn-cancel").click(function(event) {
			
			$("#btn-add-new").show('fast');
			$("#panel-form-add").hide('slow');
		}); //end click
	});// end ready
</script>

<script type="text/javascript">
     /*Form */
   $('#btn-submit-new-album').click(function()
    {
      $("#form_new_album").submit();
    });// end click

</script>  

<script type="text/javascript">

  $(document).ready(function () {

    var OfferName = $("#name");
    var OfferUrl = $("#url");
    var OfferImage = $("#image");
    var OfferPayout = $("#payout");
    var OfferCountry = $("#countryId");
   
    var FormAddOffer = $('#form-add-offer');

    FormAddOffer.validate();

    OfferName.rules("add", {
      required: true,
      messages: {
        required: "You must enter offer name."
      }
    });// end rules

    OfferUrl.rules("add", {
      required: true,
      url: true,
      messages: {
        required: "You must enter Tracking Url.",
        url: "Url is invalid"
      }
    });// end rules

    OfferImage.rules("add", {
      url: true,
      messages: {
        url: "Url is invalid"
      }
    });// end rules    

    OfferPayout.rules("add", {
      required: true,
      number: true,
      messages: {
      	required: "You must enter number for payout",
        number: "number is invalid"
      }
    });// end rules    

    OfferCountry.rules("add", {
      required: true,
      messages: {
      	required: "You must select country"
      }
    });// end rules        

});// end ready

</script>